package com.atguigu.flink03;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author Felix
 * @date 2024/2/20
 * 该案例演示了Flink执行环境的创建
 */
public class Flink01_Env {
    public static void main(String[] args) throws Exception {
        //创建本地执行环境
        //LocalStreamEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
        //创建本地执行环境  带WebUI
        //需要在pom.xml文件中  加 flink-runtime-web依赖
        //StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());

        //动态创建执行环境
        //StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //创建远程执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("hadoop102",8081,"D:\\dev\\workspace\\bigdata-0918\\flink-0918\\target\\flink-0918-1.0-SNAPSHOT.jar");

        //从文件中读取数据
        DataStreamSource<String> fileDS = env.readTextFile("/opt/module/flink-1.17.0/word.txt");
        fileDS.print();

        env.execute();
    }
}
